package com.sylvan.java.exception;

import com.sylvan.java.responsedata.HttpCode;
import com.sylvan.java.responsedata.ResponseData;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * controllerAdvice 注解使用
 *
 * @author
 * @create 2018-10-22 15:22
 **/
@RestControllerAdvice
public class testadvice {


    @ExceptionHandler(Exception.class)
    public ResponseData exception(Exception e) {

    /*    if(e instanceof MyException){
            System.out.println(e.getMessage());
        }*/
        System.out.println(e);
        return new ResponseData(HttpCode.INTERNAL_SERVER_ERROR, e.getMessage());
    }


}
